<?php
// create FFI object, loading libc and exporting function printf()
$ffi = FFI::cdef(
    "int Sum(int a,int b);", // this is a regular C declaration
    __DIR__."/libhello");
// call C's printf()
$ret = $ffi->Sum(1, 300);

var_dump($ret);


$ffi2 = FFI::cdef(
    "
    typedef struct { const char *p; ptrdiff_t n; } _GoString_;

    typedef _GoString_ GoString;

    GoString GetName(GoString p0);
    ", // this is a regular C declaration
    __DIR__."/libhello");

$p = FFI::new("struct { const char *p; ptrdiff_t n; }");
$str =  "9999";
FFI::memcpy($p->p,$str,strlen($str));
$p->ptrdiff_t = strlen($str);

var_dump($ffi2,$ffi2->GetName($p));